<template>
	<view class="shopIndex">
		<view class="bannerSwiper">
			<swiper class="swiper" indicator-dots="true" indicator-color="#dddddd" indicator-active-color="#333333">
				<swiper-item v-for="item in bannerList" :key="item.id"><image class="bannerImg" :src="item.thumb" @tap="go(item.target)"></image></swiper-item>
			</swiper>
			<view class="inputContainer">
				<view class="inputBox">
					<input type="text" class="input" placeholder="搜索楼盘" placeholder-class="placeholder" />
					<image class="search" src="../../static/index/search.png"></image>
				</view>
			</view>
		</view>
		<view class="introduce">
			<view class="title">公司介绍</view>
			<view class="introduceText">{{ shop.intro }}</view>
			<view class="nav">
				<view class="title"><text>在销楼盘</text></view>
				<view class="right" v-if="list" @tap="go('/pages/house_property/list/list')">
					<text v-for="(item, key) in list" :key="key">{{ item.name }}</text>
				</view>
			</view>
			<view class="pannel" v-for="(item, index) in shopList" :key="index" @tap="into_goods_detail(1, item.id)">
				<view class="biaoqian">
					<text v-if="item.type == 1">住宅</text>
					<text v-if="item.type == 2">别墅</text>
					<text v-if="item.type == 3">公寓</text>
					<text v-if="item.type == 4">商铺</text>
					<text v-if="item.type == 5">写字楼</text>
				</view>
				<view class="pannelleft"><image :src="item.thumb" mode="widthFix"></image></view>
				<view class="pannelright">
					<view class="pannelTitle">{{ item.name }}</view>
					<view class="redText">{{ item.avg_price }}元/平</view>
					<view class="subtitle">
						<text v-for="(val, key) in item.region" :key="key">{{ val }}</text>
					</view>
					<view class="tags">
						<view class="tag" v-for="(val, key) in item.tag_id" :key="key">{{ val }}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="foot_ad"><image v-for="(item, index) in foot_ad" :key="index" :src="item.thumb" mode="widthFix" @tap="go(item.target)"></image></view>
		<calculator></calculator>
		<view class="footer">
			<view class="index" @tap="goIndex"><uni-icons type="home" size="25"></uni-icons><text>首页</text></view>
			<view class="right">
				<view class="block" @tap="go('/pages/house_property/list/list')">
					<uni-icons type="bars" size="25"></uni-icons>
					<text>宝贝分类</text>
				</view>
				<view class="block">
				<uni-icons type="chat" size="25"></uni-icons>
					<text>联系客服</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import headNav from '@/components/house-nav/house-nav.vue';
import uniIcons from "@/components/uni-icons/uni-icons.vue";
import calculator from "@/components/calculator/calculator.vue";
export default {
	components: {
		headNav,
		uniIcons,
		calculator
	},
	data() {
		return {
			list: [
				{
					text: '11'
				},
				{
					text: '22'
				}
			],
			bannerList: [],
			shopList: [],
			page: 1,
			page_size: 10,
			noMore: false,
			shop: {},
			foot_ad: []
		};
	},
	onLoad(option) {
		this.id = option.id;
		this.getShopList();
	},
	onReachBottom() {
		let page = this.page;
		if (this.noMore) {
			page = page;
		} else {
			page = ++page;
		}
		this.page = page;
		this.getShopList();
	},
	methods: {
		getShopList() {
			this.$request
				.post('/landed/getShop', {
					data: {
						id: this.id,
						page: this.page,
						page_size: this.page_size
					}
				})
				.then(res => {
					this.shop = res.data.data.list.shop;
					this.bannerList = res.data.data.list.ad;
					this.list = res.data.data.list.shop_category;
					this.foot_ad = res.data.data.list.foot_ad;
					let shopList = this.page == 1 ? [] : this.shopList;
					this.noMore = res.data.data.list.list.length == 0 ? true : false;
					shopList.push(...res.data.data.list.list);
					this.shopList = shopList;
				});
		},
		go(url) {
			uni.navigateTo({
				url: url
			});
		},
		into_goods_detail(cid, goodsid) {
			let url = '';
			if (cid == 1) {
				url = '/pages/house_property/propertiesdetail/propertiesdetail?id=';
			} else if (cid == 2) {
				url = '/pages/house_property/seconddetail/seconddetail?id=';
			} else if (cid == 3) {
				url = '/pages/house_property/rentingdetail/rentingdetail?id=';
			}
			uni.navigateTo({
				url: url + goodsid
			});
		},
		goIndex() {
			uni.switchTab({
				url: '/pages/tabbar/tabbar-1/tabbar-1'
			});
		}
	}
};
</script>

<style lang="scss">
.nav {
	width: 100%;
	height: 80upx;
	font-size: $uni-font-size-base;
	color: $uni-text-color;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 20upx;
	box-sizing: border-box;
	.right {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		text {
			margin-left: 30upx;
			color: $uni-text-color;
			font-size: $uni-font-size-base;
		}
	}
}
.shopIndex {
	font-size: 30rpx;
	background: #f0f0f0;
	padding-bottom: 100upx;
}
.bannerSwiper {
	position: relative;
	margin-bottom: 30rpx;
	width: 100%;
	background: #fff;
}
.swiper {
	width: 100%;
	height: 380rpx;
}
.bannerImg {
	width: 100%;
	height: 100%;
}
.inputContainer {
	position: absolute;
	top: 20rpx;
	left: 10%;
	width: 80%;
}
.inputBox {
	position: relative;
	padding: 16rpx 0 16rpx 30rpx;
	width: 100%;
	background: #fff;
	border-radius: 6rpx;
	box-sizing: border-box;
}
.input {
	width: 100%;
	height: 20rpx;
}
.placeholder {
	font-size: 28rpx;
	text-align: center;
}
.search {
	position: absolute;
	width: 42rpx;
	height: 42rpx;
	top: 50%;
	right: 26rpx;
	transform: translateY(-50%);
}
.introduce {
	padding: 20rpx 24rpx 0;
	width: 100%;
	box-sizing: border-box;
	background: #fff;
}
.title {
	margin-bottom: 20rpx;
	font-size: 32rpx;
	text-align: center;
}
.content {
	display: flex;
}
.videos {
	margin-right: 10rpx;
	width: 288rpx;
	height: 204rpx;
}
.videoImg {
	width: 100%;
	height: 100%;
}
.comanyImg {
	width: calc(100% - 298rpx);
	height: 204rpx;
}
.introduceText {
	overflow: hidden;
	margin-top: 20rpx;
	width: 100%;
	white-space: normal;
	text-overflow: ellipsis;
	text-indent: 5px;
}
.videoList {
	display: flex;
	margin: 20rpx 0;
}
.videoItem {
	margin-right: 10rpx;
	width: 152rpx;
	height: 124rpx;
}
.videoItem:last-child {
	margin: 0;
}
.itemImg {
	width: 100%;
	height: 100%;
}
.pannel {
	width: 100%;
	border-bottom: 2upx solid #f8f8f8;
	padding: 10upx 20upx;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	position: relative;
}
.biaoqian {
	display: inline-block;
	box-sizing: border-box;
	padding: 0 15upx;
	line-height: 1.5em;
	border: 2upx solid #333;
	color: #333;
	font-size: $uni-font-size-base;
	position: absolute;
	top: 30upx;
	right: 20upx;
	border-radius: 10upx;
	background-color: #fff;
}
.pannelleft {
	width: 200upx;
	height: 100%;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}
.pannelleft image {
	width: 100%;
}
.pannelright {
	width: calc(100% - 200upx);
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: space-between;
	box-sizing: border-box;
	padding-left: 20upx;
	line-height: 1.5em;
	font-size: 28rpx;
	color: #555;
}
.pannelTitle {
	font-size: 32rpx;
	color: #2c405a;
}
.redText {
	color: #ed8776;
}
.subtitle {
	width: 100%;
	line-height: 1.5em;
}
.subtitle text {
	padding: 0 10upx;
	font-size: $uni-font-size-sm;
	color: #e1e1e1;
	border-right: 2upx solid #e1e1e1;
}
.subtitle text:last-of-type {
	border: none;
}
.tags {
	width: 100%;
	display: flex;
	align-items: flex-start;
	justify-content: flex-start;
	flex-wrap: wrap;
}
.tag {
	padding: 0 10rpx;
	background: #f2f1f6;
	margin-right: 20upx;
	margin-bottom: 10upx;
}
.foot_ad image {
	width: 100%;
}
.footer {
	width: 100%;
	height: 100upx;
	position: fixed;
	left: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	font-size: $uni-font-size-base;
	background-color: #fff;
	.index {
		width: 30%;
		height: 100%;
		line-height: 100upx;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
		text{
			margin-left: 10upx;
		}
	}
	.right {
		width: 70%;
		height: 100upx;
		display: flex;
		align-items: center;
		justify-content: flex-start;
		.block {
			width: 50%;
			height: 100%;
			line-height: 100upx;
			border-left: 2upx solid #bebebe;
			font-size: $uni-font-size-base;
			text-align: center;
			display: flex;
			align-items: center;
			justify-content: center;
			text{
				margin-left: 10upx;
			}
		}
	}
}
</style>
